const redis=require('../models/redis.server.model');
const map={
    reg:'注册用户'
};

module.exports=opts=>async (ctx,next)=>{
    let ret=await redis.getLimit({action:opts.action,id:ctx.request.ip}).catch(err=>console.error('Get ip limit err:',err));
    if(ret)return await ctx.render('notify',{
        loginUser:ctx.session.loginUser,
        title:'提示',
        notify:`[${map[opts.action]}]频繁，请稍候再试`
    });

    await next();
};